package com.showsu.editor.utils.remote;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.showsu.editor.entity.platform.xhs.AwemeDetailPlatformResult;
import com.showsu.editor.entity.platform.xhs.XhsAwemeDetailResult;
import com.showsu.editor.entity.r52.R52XhsAwemeCommentListResult;
import com.showsu.editor.entity.remote.batmkeyPrivate.BatmkeyPrivateXhsAwemeDetailResult;
import com.showsu.editor.entity.tikhub.TikhubXhsAwemeCommentListData;
import com.showsu.editor.entity.tikhub.TikhubXhsAwemeCommentListDataData;
import com.showsu.editor.entity.tikhub.TikhubXhsAwemeCommentListResp;
import com.showsu.editor.enums.SuccessEnum;
import com.showsu.editor.service.IRemoteInterfaceRecordService;
import com.showsu.editor.service.IRemoteInterfaceWarnSmsRecordService;
import com.showsu.editor.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;

/**
 * @Author: William
 * @Description: 单独花钱购买的接口，私享
 * @Date: Created in 8:12 下午 2023/11/20
 * @Modified By:
 */
@Slf4j
@Component
public class BatmkeyPrivateUtil {

    private static final int timeout = 50000;

    /**
     * 最多重试次数
     */
    private static final int RETRY_MAX_COUNT = 6;

    /**
     * 重试等待间隔
     */
    private static final int RETRY_WAIT_TIME = 1500;

    @Value("${batmkeyPrivate.url}")
    private String baseUrl;

    @Value("${batmkeyPrivate.token}")
    private String token;

    @Autowired
    private IRemoteInterfaceRecordService remoteInterfaceRecordService;

    @Autowired
    private IRemoteInterfaceWarnSmsRecordService remoteInterfaceWarnSmsRecordService;

    /**
     * gson反序列化时，用于忽略array的错误。因为有的时候字段返回为空，我们认为是可以接受的。
     */
    private GsonFailSafeArrayJsonDeserializer gsonFailSafeArrayJsonDeserializer = new GsonFailSafeArrayJsonDeserializer();

    private RemotePlatformRequestRateLimiter rateLimiterForXhsNoteDetailV1 = new RemotePlatformRequestRateLimiter();

    /**
     * 查询xhs笔记详情
     * @param noteId
     * @return
     */
    public XhsAwemeDetailResult getXhsAwemeDetail(String noteId, Long interfaceId) {
        if (StringUtils.isBlank(noteId)) {
            return null;
        }
        Type type = new TypeToken<AwemeDetailPlatformResult>(){}.getType();
        Gson gson = new GsonBuilder().registerTypeAdapter(List.class, gsonFailSafeArrayJsonDeserializer).create();
        XhsAwemeDetailResult result = new XhsAwemeDetailResult();
        String response = RetryUtils.retry(new Callable<String>() {
            @Override
            public String call() {
                try {
                    long start = System.currentTimeMillis();
                    StringBuilder url = new StringBuilder(baseUrl).append("/api/xhs/note/detail?key=").append(token).append("&note_id=").append(noteId);
                    String responseInner = HttpUtil.get(url.toString(), timeout);
                    log.info("BatmkeyPrivateUtil查询xhs作品详情-响应耗时:{}-noteId:{}, responseInner:{}", System.currentTimeMillis() - start, noteId, responseInner);
                    AwemeDetailPlatformResult temp = gson.fromJson(responseInner, type);
                    if (temp != null
                            && (Constant.containsXhsAwemeNotExistHint(StringUtil.convertUnicodeToChinese(temp.getMsg()))
                                || Constant.containsXhsAwemeNotExistHint(StringUtil.convertUnicodeToChinese(temp.get_msg()))
                                || (!CollectionUtils.isEmpty(temp.getData())
                                        && temp.getData().get(0) != null
                                        && !CollectionUtils.isEmpty(temp.getData().get(0).getNote_list())
                                        && Constant.containsXhsAwemeNotExistHint(StringUtil.convertUnicodeToChinese(temp.getData().get(0).getNote_list().get(0).getText()))
                                    )
                                )
                    ) {
                        remoteInterfaceRecordService.add(interfaceId, SuccessEnum.SUCCESS.getCode());
                        return Constant.xhsAwemeNotExist0;
                    }
                    //如果平台那边报错再重试一次
                    if (temp == null || (temp != null && temp.getCode() != null && temp.getCode().intValue() != 0)) {
                        remoteInterfaceRecordService.add(interfaceId, SuccessEnum.FAIL.getCode());
                        return "";
                    }
                    remoteInterfaceRecordService.add(interfaceId, SuccessEnum.SUCCESS.getCode());
                    return responseInner;
                } catch (Exception e) {
                    remoteInterfaceRecordService.add(interfaceId, SuccessEnum.FAIL.getCode());
                    log.error("BatmkeyPrivateUtil.getXhsAwemeDetail(String) error, noteId:{}, e:{}", noteId, e);
                    return "";
                }
            }
        }, RETRY_MAX_COUNT, RETRY_WAIT_TIME);
        if (StringUtils.isBlank(response)) {
            remoteInterfaceWarnSmsRecordService.sendWarnSmsIn15mins(interfaceId,
                    new StringBuilder("noteId=").append(noteId).toString());
            return result;
        }
        if (response.equals(Constant.xhsAwemeNotExist0)) {
            return null;
        }
        try {
            AwemeDetailPlatformResult awemeDetailPlatformResult = gson.fromJson(response, type);
            result.setData(awemeDetailPlatformResult);
        } catch (Exception e) {
            log.error("BatmkeyPrivateUtil.getXhsAwemeDetail(String) convert error, noteId:{}, e:{}", noteId, e);
        }
        return result;
    }

    /**
     * 查询xhs笔记详情，20240125提供的一个新接口
     * @param noteId
     * @return
     */
    public XhsAwemeDetailResult getXhsAwemeDetail2(String noteId, Long interfaceId) {
        if (StringUtils.isBlank(noteId)) {
            return null;
        }
        Type type = new TypeToken<BatmkeyPrivateXhsAwemeDetailResult>(){}.getType();
        Gson gson = new GsonBuilder().registerTypeAdapter(List.class, gsonFailSafeArrayJsonDeserializer).create();
        XhsAwemeDetailResult result = new XhsAwemeDetailResult();
        String response = RetryUtils.retry(new Callable<String>() {
            @Override
            public String call() {
                try {
                    long start = System.currentTimeMillis();
                    StringBuilder url = new StringBuilder(baseUrl).append("/api/xhs/note/page?key=").append(token).append("&note_id=").append(noteId);
                    String responseInner = HttpUtil.get(url.toString(), timeout);
                    log.info("BatmkeyPrivateUtil查询xhs作品详情2-响应耗时:{},noteId:{},responseInner:{}", System.currentTimeMillis() - start, noteId, responseInner);
                    JSONObject jsonObject = JSON.parseObject(responseInner);
                    if (jsonObject != null && jsonObject.get("msg") != null && Constant.containsXhsAwemeNotExistHint(StringUtil.convertUnicodeToChinese(jsonObject.getString("msg")))) {
                        remoteInterfaceRecordService.add(interfaceId, SuccessEnum.SUCCESS.getCode());
                        return Constant.xhsAwemeNotExist0;
                    }
                    BatmkeyPrivateXhsAwemeDetailResult temp = gson.fromJson(responseInner, type);
                    //如果平台那边报错再重试一次
                    if (temp == null || temp.getData() == null || (temp != null && temp.getCode() != null && temp.getCode().intValue() != 0)) {
                        remoteInterfaceRecordService.add(interfaceId, SuccessEnum.FAIL.getCode());
                        return "";
                    }
                    remoteInterfaceRecordService.add(interfaceId, SuccessEnum.SUCCESS.getCode());
                    return responseInner;
                } catch (Exception e) {
                    remoteInterfaceRecordService.add(interfaceId, SuccessEnum.FAIL.getCode());
                    log.error("BatmkeyPrivateUtil.getXhsAwemeDetail2(String) error, noteId:{}, e:{}", noteId, e);
                    return "";
                }
            }
        }, RETRY_MAX_COUNT, RETRY_WAIT_TIME);
        if (StringUtils.isBlank(response)) {
            remoteInterfaceWarnSmsRecordService.sendWarnSmsIn15mins(interfaceId,
                    new StringBuilder("noteId=").append(noteId).toString());
            return result;
        }
        if (response.equals(Constant.xhsAwemeNotExist0)) {
            return null;
        }
        try {
            BatmkeyPrivateXhsAwemeDetailResult batmkeyPrivateXhsAwemeDetailResult = gson.fromJson(response, type);
            if (batmkeyPrivateXhsAwemeDetailResult != null && batmkeyPrivateXhsAwemeDetailResult.getData() != null
                    && batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card() != null) {
                result.setCode(batmkeyPrivateXhsAwemeDetailResult.getCode());

                AwemeDetailPlatformResult awemeDetailPlatformResult = new AwemeDetailPlatformResult();
                result.setData(awemeDetailPlatformResult);
                List<AwemeDetailPlatformResult.AwemeDetail> awemeDetailList = new ArrayList<>();
                awemeDetailPlatformResult.setData(awemeDetailList);
                AwemeDetailPlatformResult.AwemeDetail awemeDetail = awemeDetailPlatformResult.new AwemeDetail();
                awemeDetailList.add(awemeDetail);
                AwemeDetailPlatformResult.AwemeDetail.User user = awemeDetail.new User();
                awemeDetail.setUser(user);
                List<AwemeDetailPlatformResult.AwemeDetail.Note> noteList = new ArrayList<>();
                AwemeDetailPlatformResult.AwemeDetail.Note note = awemeDetail.new Note();
                noteList.add(note);
                awemeDetail.setNote_list(noteList);

                if (batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getUser() != null) {
                    user.setUserid(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getUser().getUser_id());
                    user.setNickname(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getUser().getNickname());
                    user.setImage(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getUser().getAvatar());
                }

                if (batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getInteract_info() != null) {
                    note.setLiked_count(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getInteract_info().getLiked_count());
                    note.setCollected(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getInteract_info().getCollected());
                    note.setCollected_count(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getInteract_info().getCollected_count());
                    note.setComments_count(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getInteract_info().getComment_count());
                    note.setShared_count(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getInteract_info().getShare_count());
                }

                if (! CollectionUtils.isEmpty(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getImage_list())) {
                    List<AwemeDetailPlatformResult.AwemeDetail.Note.Image> imageList = new ArrayList<>();
                    note.setImages_list(imageList);
                    for (BatmkeyPrivateXhsAwemeDetailResult.BatmkeyPrivateXhsAwemeDetailData.Note.Cover cover : batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getImage_list()) {
                        AwemeDetailPlatformResult.AwemeDetail.Note.Image image = note.new Image();
                        image.setFileid(cover.getFileid());
                        image.setHeight(cover.getHeight());
                        image.setWidth(cover.getWidth());
                        image.setUrl(cover.getUrl());
                        if(! CollectionUtils.isEmpty(cover.getInfo_list())){
                            for(BatmkeyPrivateXhsAwemeDetailResult.BatmkeyPrivateXhsAwemeDetailData.Note.Cover.CoverInfo infoList : cover.getInfo_list()){
                                if(Constant.CRD_WM_WEBP.equals(infoList.getImage_scene())){
                                    image.setOriginal(infoList.getUrl());
                                }
                            }
                        }
                        if(cover.getStream() != null && !CollectionUtils.isEmpty(cover.getStream().getH264())){
                            AwemeDetailPlatformResult.AwemeDetail.Note.Image.LivePhoto livePhoto = image.new LivePhoto();
                            AwemeDetailPlatformResult.AwemeDetail.Note.Image.LivePhoto.Media media = livePhoto.new Media();
                            AwemeDetailPlatformResult.AwemeDetail.Note.Image.LivePhoto.Media.Stream stream = media.new Stream();
                            List<AwemeDetailPlatformResult.AwemeDetail.Note.Image.LivePhoto.Media.Stream.H264> h264List = new ArrayList<>();
                            for (BatmkeyPrivateXhsAwemeDetailResult.BatmkeyPrivateXhsAwemeDetailData.Note.Cover.Stream.H264 h264 : cover.getStream().getH264()) {
                                AwemeDetailPlatformResult.AwemeDetail.Note.Image.LivePhoto.Media.Stream.H264 h264_1 = stream.new H264();
                                h264_1.setMaster_url(h264.getMaster_url());
                                h264List.add(h264_1);
                            }
                            stream.setH264(h264List);
                            media.setStream(stream);
                            livePhoto.setMedia(media);
                            image.setLive_photo(livePhoto);
                        }
                        imageList.add(image);
                    }
                    if (! CollectionUtils.isEmpty(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getImage_list().get(0).getInfo_list())) {
                        AwemeDetailPlatformResult.AwemeDetail.Note.ShareInfo shareInfo = note.new ShareInfo();
                        shareInfo.setImage(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getImage_list().get(0).getInfo_list().get(0).getUrl());
                        note.setShare_info(shareInfo);
                    }

                }

                AwemeDetailPlatformResult.AwemeDetail.Note.ShareInfo shareInfo = note.new ShareInfo();
                note.setShare_info(shareInfo);

                //笔记文案
                if (StringUtils.isNotBlank(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getTitle())) {
                    shareInfo.setTitle(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getTitle());
                }

                note.setTitle(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getTitle());
                note.setType(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getType());
                note.setDesc(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getDesc());
                note.setTime(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getTime());
                note.setLast_update_time(batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getLast_update_time());
                List<AwemeDetailPlatformResult.AwemeDetail.Note.HashTagDTO> hashTagDTOList=new ArrayList<>();
                for(BatmkeyPrivateXhsAwemeDetailResult.BatmkeyPrivateXhsAwemeDetailData.Note.Tag tag :batmkeyPrivateXhsAwemeDetailResult.getData().getNote_card().getTag_list()){
                    AwemeDetailPlatformResult.AwemeDetail.Note.HashTagDTO hashTag= new AwemeDetailPlatformResult().new AwemeDetail().new Note().new HashTagDTO();
                    hashTag.setId(tag.getId());
                    hashTag.setName(tag.getName());
                    hashTagDTOList.add(hashTag);
                }
                note.setHash_tag(hashTagDTOList);
            }
        } catch (Exception e) {
            log.error("BatmkeyPrivateUtil.getXhsAwemeDetail2(String) convert error, noteId:{}, e:{}", noteId, e);
        }
        return result;
    }

    /**
     * 查询xhs笔记详情
     * 20240203新提供的一个接口，这个里头是有实况图相关字段的
     * @param noteId
     * @return
     */
    public XhsAwemeDetailResult getXhsAwemeDetail3(String noteId, Long interfaceId) {
        if (StringUtils.isBlank(noteId)) {
            return null;
        }
        Type type = new TypeToken<AwemeDetailPlatformResult>(){}.getType();
        Gson gson = new GsonBuilder().registerTypeAdapter(List.class, gsonFailSafeArrayJsonDeserializer).create();
        XhsAwemeDetailResult result = new XhsAwemeDetailResult();
        long rate=4000l;
        String response = RetryUtils.retry(new Callable<String>() {
            @Override
            public String call() {
                try {
                    long start = System.currentTimeMillis();
                    StringBuilder url = new StringBuilder(baseUrl).append("/api/xhs/note/detail/v1?key=").append(token).append("&note_id=").append(noteId);
                    String responseInner = rateLimiterForXhsNoteDetailV1.sendGetRequestAndReturnXhsAwemeDetailPlatformResultString(url.toString(), timeout, rate);
                    log.info("BatmkeyPrivateUtil查询xhs作品详情3-响应耗时:{}-noteId:{}, responseInner:{}", System.currentTimeMillis() - start, noteId, responseInner);
                    AwemeDetailPlatformResult temp = gson.fromJson(responseInner, AwemeDetailPlatformResult.class);
                    //如果平台那边报错再重试一次
                    if (temp == null) {
                        remoteInterfaceRecordService.add(interfaceId, SuccessEnum.FAIL.getCode());
                        return "";
                    }
                    //捕获请求频率过快的异常
                    if (temp.getCode() == 103 && Constant.batmkeyPrivaterRteLimiterMsg.equals(temp.getMsg())) {
                        log.info("BatmkeyPrivateUtil查询xhs作品详情3-捕获到请求频率过快一场-noteId:{}", noteId);
                        remoteInterfaceRecordService.add(interfaceId, SuccessEnum.FAIL.getCode());
                        AwemeDetailPlatformResult result1 = new AwemeDetailPlatformResult();
                        result1.setCode(103);
                        result1.setMsg(Constant.batmkeyPrivaterRteLimiterMsg);
                        result1.setStatus_code(200);
                        return JSON.toJSONString(result1);
//                        return responseInner;
                    }
                    if (temp != null
                            && (Constant.containsXhsAwemeNotExistHint(StringUtil.convertUnicodeToChinese(temp.getMsg()))
                                || Constant.containsXhsAwemeNotExistHint(StringUtil.convertUnicodeToChinese(temp.get_msg()))
                                || (!CollectionUtils.isEmpty(temp.getData())
                                    && temp.getData().get(0) != null
                                    && !CollectionUtils.isEmpty(temp.getData().get(0).getNote_list())
                                    && Constant.containsXhsAwemeNotExistHint(StringUtil.convertUnicodeToChinese(temp.getData().get(0).getNote_list().get(0).getText())))
                            )
                    ) {
                        remoteInterfaceRecordService.add(interfaceId, SuccessEnum.SUCCESS.getCode());
                        return Constant.xhsAwemeNotExist0;
                    }
                    //如果平台那边报错再重试一次
                    if (temp.getCode() != null && temp.getCode()!= 0) {
                        remoteInterfaceRecordService.add(interfaceId, SuccessEnum.FAIL.getCode());
                        return "";
                    }
                    remoteInterfaceRecordService.add(interfaceId, SuccessEnum.SUCCESS.getCode());
                    return responseInner;
                } catch (Exception e) {
                    remoteInterfaceRecordService.add(interfaceId, SuccessEnum.FAIL.getCode());
                    log.error("BatmkeyPrivateUtil.getXhsAwemeDetail3(String, Long) error, noteId:{}, e:{}", noteId, e);
                    return "";
                }
            }
        }, RETRY_MAX_COUNT, RETRY_WAIT_TIME);
        if (StringUtils.isBlank(response)) {
            remoteInterfaceWarnSmsRecordService.sendWarnSmsIn15mins(interfaceId,
                    new StringBuilder("noteId=").append(noteId).toString());
            return result;
        }
        if (response.equals(Constant.xhsAwemeNotExist0)) {
            return null;
        }
        try {
            AwemeDetailPlatformResult awemeDetailPlatformResult = gson.fromJson(response, type);
            if (awemeDetailPlatformResult != null
                    && !CollectionUtils.isEmpty(awemeDetailPlatformResult.getData())
                    && awemeDetailPlatformResult.getData().get(0) != null
                    && !CollectionUtils.isEmpty(awemeDetailPlatformResult.getData().get(0).getNote_list())
                    && awemeDetailPlatformResult.getData().get(0).getNote_list().get(0) != null
                    && StringUtils.isNotBlank(awemeDetailPlatformResult.getData().get(0).getNote_list().get(0).getText())
                    && Constant.containsXhsAwemeNotExistHint(awemeDetailPlatformResult.getData().get(0).getNote_list().get(0).getText())) {
                return null;
            }
            result.setData(awemeDetailPlatformResult);
        } catch (Exception e) {
            log.error("BatmkeyPrivateUtil.getXhsAwemeDetail3(String, Long) convert error, noteId:{}, e:{}", noteId, e);
        }
        return result;
    }

    /**
     * 获取xhs笔记评论数据
     * @param noteId
     * @param cursor 评论 start⾸次传空 翻⻚是最后⼀个评论id
     * @return
     */
    public TikhubXhsAwemeCommentListResp getXhsAwemeCommentList(String noteId, String cursor, Long interfaceId) {
        if (StringUtils.isBlank(noteId)) {
            return null;
        }
        TikhubXhsAwemeCommentListResp result = new TikhubXhsAwemeCommentListResp();
        TikhubXhsAwemeCommentListData data = new TikhubXhsAwemeCommentListData();
        Type type = new TypeToken<R52XhsAwemeCommentListResult>(){}.getType();
        Gson gson = new Gson();
        String response = RetryUtils.retry(new Callable<String>() {
            @Override
            public String call() {
                try {
                    long start = System.currentTimeMillis();
                    StringBuilder url = new StringBuilder(baseUrl).append("/api/xhs/note/comment?key=").append(token)
                            .append("&start=").append(cursor).append("&note_id=").append(noteId);
                    String responseInner = HttpUtil.get(url.toString(), timeout);
                    log.info("BatmkeyPrivateUtil查询xhs作品评论数据-响应耗时:{}, noteId:{}, cursor:{}",
                            System.currentTimeMillis() - start, noteId, cursor);
                    R52XhsAwemeCommentListResult temp = gson.fromJson(responseInner, type);
                    //如果平台那边报错再重试一次
                    if (temp != null && temp.getCode() != null && temp.getCode().intValue() != 0) {
                        remoteInterfaceRecordService.add(interfaceId, SuccessEnum.FAIL.getCode());
                        return "";
                    }
                    remoteInterfaceRecordService.add(interfaceId, SuccessEnum.SUCCESS.getCode());
                    return responseInner;
                } catch (Exception e) {
                    remoteInterfaceRecordService.add(interfaceId, SuccessEnum.FAIL.getCode());
                    log.error("BatmkeyPrivateUtil.getXhsAwemeCommentList(String,String) error, noteId:{}, cursor:{}, e:{}", noteId, cursor, e);
                    return "";
                }
            }
        }, RETRY_MAX_COUNT, RETRY_WAIT_TIME);
        if (StringUtils.isBlank(response)) {
            remoteInterfaceWarnSmsRecordService.sendWarnSmsIn15mins(interfaceId,
                    new StringBuilder("noteId=").append(noteId).append(",cursor=").append(cursor).toString());
            return result;
        }
        try {
            R52XhsAwemeCommentListResult originResult = gson.fromJson(response, type);
            if (originResult != null && originResult.getData() != null && !CollectionUtils.isEmpty(originResult.getData().getComments())) {
                data.setCode(originResult.getCode());
                data.setMsg(originResult.getMsg());
                TikhubXhsAwemeCommentListDataData dataData = new TikhubXhsAwemeCommentListDataData();
                dataData.setComments(originResult.getData().getComments());
                dataData.setComment_count(originResult.getData().getComment_count());
                dataData.setComment_count_l1(originResult.getData().getComment_count_l1());
                dataData.setCursor(originResult.getData().getComments().get(originResult.getData().getComments().size() - 1).getId());
                data.setData(dataData);
                data.initVideoInfo();
            }
            result.setData(data);
        } catch (Exception e) {
            log.error("BatmkeyPrivateUtil.getXhsAwemeCommentList(String,String) convert error, noteId:{}, cursor:{}, e:{}", noteId, cursor, e);
        }
        return result;
    }
    public static void main(String[] args) {
        //String response = HttpUtil.get("http://shuxiu.apitime.batmkey.cn:8061/api/xhs/user/post/v1?key=53e8d20e-3ffc-4f3e-83e3-020904844f261700218314348&user_id=5af91f874eacab18df204e18&page=");
        //String response = HttpUtil.get("http://shuxiu.apitime.batmkey.cn:8061/api/xhs/note/detail?key=53e8d20e-3ffc-4f3e-83e3-020904844f261700218314348&note_id=665919ce000000000f00c212");
        String response = HttpUtil.get("http://shuxiu.apitime.batmkey.cn:8061/api/xhs/note/detail/v1?key=53e8d20e-3ffc-4f3e-83e3-020904844f261700218314348&note_id=65eefc2700000000120219c2");
        //String response = HttpUtil.get("http://shuxiu.apitime.batmkey.cn:8061/api/xhs/note/page?key=53e8d20e-3ffc-4f3e-83e3-020904844f261700218314348&note_id=65ef2202000000001203dbc4");
        //String response = HttpUtil.get("http://shuxiu.apitime.batmkey.cn:8061/api/xhs/note/detail/v2?key=53e8d20e-3ffc-4f3e-83e3-020904844f261700218314348&note_id=66a89a13000000002701387c");
        System.out.println(response);
    }
}
